{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "97e3f98e-f224-42bc-9386-53da868ce7f9",
   "metadata": {},
   "source": [
    "# Logic Analyzer\n",
    "\n",
    "In the previous tutorial we saw that the oscilloscope is not the ideal instrument for looking at digital signals. The PSLab has another instrument more suited for this purpose: The logic analyzer.\n",
    "\n",
    "The PSLab's oscilloscope struggles with digital signals with frequencies over 50 kHz. Let's see how the logic analyzer does. This time, connect SQ1 to LA1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6fe26b39-0284-4729-8f4d-f4f621b13bb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fc3affb7790>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGdCAYAAADAAnMpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAepklEQVR4nO3df1TVhf3H8Rdc5aILySIugij200xFg8FB61SLxZyHzbOzxswlw3KnBmfoPbWkEmousc5kdIokLWvnLI9US9em6YhFHk90UIid3EpnlnAyQE7FJSxo997vHzvRl4nlxXt9x+X5OOfzhx8+n899f85nzaef+7ncCL/f7xcAAICRSOsBAADA6EaMAAAAU8QIAAAwRYwAAABTxAgAADBFjAAAAFPECAAAMEWMAAAAU2OsBzgdPp9Px44dU0xMjCIiIqzHAQAAp8Hv96unp0eJiYmKjDz1/Y8RESPHjh1TcnKy9RgAAGAY2traNHny5FP+fETESExMjKT/nsyECROMpwEAAKfD4/EoOTl54O/xUxkRMfLFWzMTJkwgRgAAGGG+7hELHmAFAACmiBEAAGCKGAEAAKaIEQAAYIoYAQAApogRAABgihgBAACmiBEAAGCKGAEAAKYCjpE9e/YoNzdXiYmJioiI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OQes7OjqUkJAw5D4JCQkBbS9JTqdTTqczkNECFhERofFR38gWg7g+4YbrGV64nuHjm3ItA3qbJioqSmlpaaqrqxtY5/P5VFdXp6ysrCH3ycrKGrS9JNXW1p5yewAAMLoEnENut1v5+flKT09XRkaGKisr1dvbO/DpmqVLlyopKUnl5eWSpOLiYl1zzTVav369Fi5cqK1bt2r//v3auHFjcM8EAACMSAHHSF5eno4fP67S0lK1t7drzpw52rVr18BDqq2trYqM/PKGy7x587Rlyxbde++9uvvuu3XJJZdo+/btmjlzZvDOAgAAjFgRfr/fbz3E1/F4PIqNjVV3d7cmTJhgPQ4AADgNp/v3N99NAwAATBEjAADAFDECAABMESMAAMAUMQIAAEwRIwAAwBQxAgAATBEjAADAFDECAABM2X9V32n44pfEejwe40kAAMDp+uLv7a/7Ze8jIkZ6enokScnJycaTAACAQPX09Cg2NvaUPx8R303j8/l07NgxxcTEKCIiImjH9Xg8Sk5OVltbW1h/5w3nGV44z/DCeYYXznMwv9+vnp4eJSYmDvoS3f81Iu6MREZGavLkySE7/oQJE8L6fzRf4DzDC+cZXjjP8MJ5fumr7oh8gQdYAQCAKWIEAACYGtUx4nQ6VVZWJqfTaT1KSHGe4YXzDC+cZ3jhPIdnRDzACgAAwteovjMCAADsESMAAMAUMQIAAEwRIwAAwNSojpGqqiqlpKQoOjpamZmZamxstB4pqPbs2aPc3FwlJiYqIiJC27dvtx4pJMrLy/Xtb39bMTExio+P16JFi3Tw4EHrsYJuw4YNmj179sAvGcrKytJLL71kPVZIrVu3ThEREVqxYoX1KEF33333KSIiYtAyffp067FC4v3339fPfvYznX/++Ro3bpxmzZql/fv3W48VVCkpKSddz4iICBUWFlqPFjRer1erV6/WtGnTNG7cOF100UVas2bN137vzOkYtTFSU1Mjt9utsrIyNTc3KzU1VTk5Oers7LQeLWh6e3uVmpqqqqoq61FC6tVXX1VhYaFef/111dbW6vPPP9cNN9yg3t5e69GCavLkyVq3bp2ampq0f/9+fec739EPf/hD/fOf/7QeLST27dun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Ojs7deWVVw6s83q92rNnjx599FH19fXJ4XAYThg65557ri699FIdPnzYepSgmjRp0kmxfPnll+tPf/qT0UShdfToUb388st64YUXrEcJujvvvFOrVq3ST3/6U0nSrFmzdPToUZWXl59xjIzKZ0aioqKUlpamurq6gXU+n091dXVh+f57uPP7/SoqKtK2bdv097//XdOmTbMe6azx+Xzq6+uzHiNorr/+er355ptqaWkZWNLT07VkyRK1tLSEbYhI0ieffKJ33nlHkyZNsh4lqObPn3/SR+0PHTqkqVOnGk0UWk899ZTi4+O1cOFC61GC7sSJE4qMHJwNDodDPp/vjI89Ku+MSJLb7VZ+fr7S09OVkZGhyspK9fb2qqCgwHq0oPnkk08G/Svr3XffVUtLi8477zxNmTLFcLLgKiws1JYtW/TnP/9ZMTExam9vlyTFxsZq3LhxxtMFT0lJiRYsWKApU6aop6dHW7ZsUX19vXbv3m09WtDExMSc9KzPt771LZ1//vlh9wzQHXfcodzcXE2dOlXHjh1TWVmZHA6HFi9ebD1aUK1cuVLz5s3T2rVr9ZOf/ESNjY3auHGjNm7caD1a0Pl8Pj311FPKz8/XmDHh99drbm6uHnjgAU2ZMkVXXHGF3njjDVVUVGjZsmVnfvAz/jzOCPbII4/4p0yZ4o+KivJnZGT4X3/9deuRguqVV17xSzppyc/Ptx4tqIY6R0n+p556ynq0oFq2bJl/6tSp/qioKP8FF1zgv/766/1/+9vfrMcKuXD9aG9eXp5/0qRJ/qioKH9SUpI/Ly/Pf/jwYeuxQuIvf/mLf+bMmX6n0+mfPn26f+PGjdYjhcTu3bv9kvwHDx60HiUkPB6Pv7i42D9lyhR/dHS0/8ILL/Tfc889/r6+vjM+doTfH4RfnQYAADBMo/KZEQAA8M1BjAAAAFPECAAAMEWMAAAAU8QIAAAwRYwAAABTxAgAADBFjAAAAFPECAAAMEWMAAAAU8QIAAAwRYwAAABT/wfWTzME5MiA+AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import pslab\n",
    "psl = pslab.ScienceLab()\n",
    "psl.pwm_generator.generate(channels=\"SQ1\", frequency=500_000, duty_cycles=0.5)\n",
    "t = psl.logic_analyzer.capture(channels=\"LA1\", events=8)\n",
    "x, y = psl.logic_analyzer.get_xy(t)\n",
    "plt.plot(x, y)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4ae5fb02-eb22-42e9-8f83-308d6a4816e6",
   "metadata": {},
   "source": [
    "Much better!\n",
    "\n",
    "The logic analyzer also has four channels, so we can use it to look at all the PWM outputs simultaneously. Connect SQ2 to LA2, SQ3 to LA3, and SQ4 to LA4."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "cd8a3999-ab4a-414c-88bf-88aa4a183abf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fc3af9c6790>,\n",
       " <matplotlib.lines.Line2D at 0x7fc3af9c6b90>,\n",
       " <matplotlib.lines.Line2D at 0x7fc3af9c6e90>,\n",
       " <matplotlib.lines.Line2D at 0x7fc3af9c7190>]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhYAAAGdCAYAAABO2DpVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8g+/7EAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAbBklEQVR4nO3df5CdBXno8edkk91scHcLaJA1m4CiUMCkJJE0Ri2FVJphMjLOVdqbjpE4zthZbNKMVaJXo2Nh0WkZHWACWIXOSAawNWDtQBrTJhluCeQHcUAtSnVopgGiM3Y3hHUTd9/7h8NKLgSym+fse867n8/M+WNPzp7zvPss7DfnPZtTK4qiCACABFPKHgAAqA5hAQCkERYAQBphAQCkERYAQBphA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OpXvxq33XbbK96+ra0t2traTm5KAKApnPS/YzEyMnLMaygAgMlrTM9YrFu3LpYtWxazZ8+OQ4cOxcaNG2Pbtm2xefPmes0HADSRMYXFwYMH40Mf+lA888wz0dXVFXPnzo3NmzfHH/3RH9VrPgCgiYwpLL7+9a/Xaw4AoAK8VwgAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABphAUAkEZYAABpppY9QIaiKGLw14Pp91uP+2xUk+FYJ8MxvtRkON7JcIwvmgzHOhmOcTKoRFgM/nowFm1cVPYYTe2Sey8pewSS2Wm12CfNwqmQE3DRzIuifWp72WOka5/aHhfNvKjsMSZcVfcZYadVY580o1pRFMVEPuDAwEB0dXVFf39/dHZ2ptxnvU6FvKh9anvUarW63X+Z6v21a0RV3meEnVaNfVbHS3fZjMd4oj+/K3EqpFarxYxpM8oeoyn52lWPnVaLfVbHZNmlUyEAQBphAQCkqcSpkEorioijL5Q9xW9NmxHRZOcFG0qj7TPCTk9Wo+3UPk+OfZ40YdHIiiLiG5dH7H+k7El+q+f3I1Y92HTf6A2hEfcZYacnoxF3ap/jZ58pnAppZEdfaKxv8IiI/Tsbq+abSSPuM8JOT0Yj7tQ+x88+U3jGoll84qmI1hJfTXzkhYi/Oae8x6+asvcZYafZyt6pfeayz3ETFs2idUZE6yllT0EW+6weO60W+xw3p0IAgDRjCou+vr54xzveER0dHTFz5sy48sor48knn6zXbABAkxlTWGzfvj16e3tj586dsWXLljh69Gi8973vjcOHD9drPgCgiYzpNRYPPvjgMR/feeedMXPmzNizZ0+85z3vSR0MAGg+J/Xizf7+/oiIOO200457m6GhoRgaGhr9eGBg4GQeEgBoYON+8ebIyEisWbMmlixZEhdeeOFxb9fX1xddXV2jl56envE+JADQ4MYdFr29vfHEE0/E3Xff/aq3W7duXfT3949e9u/fP96HBAAa3LhOhVxzzTXx3e9+N3bs2BGzZs161du2tbVFW1vbuIYDAJrLmMKiKIr4+Mc/Hps2bYpt27bF2WefXa+5AIAmNKaw6O3tjY0bN8b9998fHR0d8eyzz0ZERFdXV7S3t9dlQACgeYzpNRYbNmyI/v7+uOSSS+LMM88cvdxzzz31mg8AaCJjPhUCAHA83isEAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANFPLHiBFUUQcfaHsKfIdadBjatS5Gl0jf90aebZG1qhft0adq9H5uqWoRlgcfSHi+u6yp5g8/uacsicgm51Wi31SIqdCmkHP70dMm1HuDNNm/GYOTl4j7DPCTjM1wk7tM08j7LOJ1YqiKCbyAQcGBqKrqyv6+/ujs7Mz506reirkRdNmRNRqZU9R/a/zRGmUfUbYaZZG2al95miEfb50l40wT5z4z+9qnAqp1SJaTyl7iurzda4eO60W+6yOJt7lmE+F7NixI5YvXx7d3d1Rq9Xivvvuq8NYAEAzGnNYHD58OObNmxe33HJLPeYBAJrYmE+FLFu2LJYtW1aPWSaNoihi8OjwCd22fVpL1Brg3BrHZ5/VY6fVYp8Tq+6vsRgaGoqhoaHRjwcGBur9kA2tKIr4X7c+HHue/uUJ3X7hnFPjWx9b7Bu9Qdln9dhptdjnxKv7r5v29fVFV1fX6K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ee80jMWPT090d/fH52dnSc5/m8006mQF7VPa4larfaqt2nG45qs7LN67LRaXmufL93liex+MhoYGIiurq7X/Pk9plMhr3/966OlpSWee+65Y65/7rnn4o1vfOMrfk5bW1u0tbWN5WHGrFarxYzWMb9cpOFV9bgmK/usHjutDrvMM6ZTIa2trbFgwYLYunXr6HUjIyOxdevWY57BAAAmpzHn2dq1a2PlypWxcOHCuPjii+MrX/lKHD58ePS3RACAyWvMYXHVVVfFz3/+8/jc5z4Xzz77bPze7/1ePPjggy97QScAMPmM6cWbGU70xR8AQOM40Z/f3isEAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgjLACANMICAEgz4W/l9uI/9DkwMDDRDw0AjNOLP7df6x/snvCwOHToUERE9PT0TPRDAwAn6dChQ9HV1XXcP5/w9woZGRmJAwcOREdHR9RqtbT7HRgYiJ6enti/f3+l34NkshxnxOQ5VsdZLY6zWibLcUa89rEWRRGHDh2K7u7umDLl+K+kmPBnLKZMmRKzZs2q2/13dnZWfvkRk+c4IybPsTrOanGc1TJZjjPi1Y/11Z6peJEXbwIAaYQFAJCmMmHR1tYW69evj7a2trJHqavJcpwRk+dYHWe1OM5qmSzHGZF3rBP+4k0AoLoq84wFAFA+YQEApBEWAEAaYQEApKlMWNxyyy1x1llnxfTp02PRokXx6KOPlj1Sqh07dsTy5cuju7s7arVa3HfffWWPVBd9fX3xjne8Izo6OmLmzJlx5ZVXxpNPPln2WOk2bNgQc+fOHf2HaBYvXhwPPPBA2WPV3Q033BC1Wi3WrFlT9ijpPv/5z0etVjvmct5555U9Vl3893//d/zZn/1ZnH766dHe3h5vf/vbY/fu3WWPleqss8562T5rtVr09vaWPVqq4eHh+OxnPxtnn312tLe3x1ve8pb44he/+JrvB/JqKhEW99xzT6xduzbWr18fe/fujXnz5sXll18eBw8eLHu0NIcPH4558+bFLbfcUvYodbV9+/bo7e2NnTt3xpYtW+Lo0aPx3ve+Nw4fPlz2aKlmzZoVN9xwQ+zZsyd2794dl156abzvfe+LH/zg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z+9a+PlpaWeO655465/rnnnos3vvGNJU3Fybrmmmviu9/9buzYsSNmzZpV9jh10draGuecc05ERCxYsCB27doVX/3qV+O2224rebI8e/bsiYMHD8b8+fNHrxseHo4dO3bEzTffHENDQ9HS0lLihPXzO7/zO/G2t70tnnrqqbJHSXXmmWe+LH5/93d/N/7xH/+xpInq6+mnn47vfe978e1vf7vsUerir/7qr+Laa6+NP/mTP4mIiLe//e3x9NNPR19f37jDoulfY9Ha2hoLFiyIrVu3jl43MjISW7durez56ioriiKuueaa2LRpU/zrv/5rnH322WWPNGFGRkZiaGio7DFSXXbZZfH444/Hvn37Ri8LFy6MFStWxL59+yobFRERzz//fPznf/5nnHnmmWWPkmrJkiUv+xXwH//4xzFnzpySJqqvO+64I2bOnBlXXHFF2aPUxQsvvBBTphybAi0tLTEyMjLu+2z6ZywiItauXRsrV66MhQsXxsUXXxxf+cpX4vDhw3H11VeXPVqa559//pi/+fzsZz+Lffv2xWmnnRazZ88ucbJcvb29sXHjxrj//vujo6Mjnn322YiI6Orqivb29pKny7Nu3bpYtmxZzJ49Ow4dOhQbN26Mbdu2xebNm8seLVVHR8fLXh9zyimnxOmnn16518184hOfiOXLl8ecOXPiwIEDsX79+mhpaYk//dM/LXu0VH/5l38Z73znO+P666+PD37wg/Hoo4/G7bffHrfffnvZo6UbGRmJO+64I1auXBlTp1bix+XLLF++PK677rqYPXt2XHDBBfHYY4/FjTfeGKtWrRr/nZ7kb6o0jJtuuqmYPXt20draWlx88cXFzp07yx4p1b/9278VEfGyy8qVK8seLdUrHWNEFHfccUfZo6VatWpVMWfOnKK1tbV4wxveUFx22WXFv/zLv5Q91oSo6q+bXnXVVcWZZ55ZtLa2Fm9605uKq666qnjqqafKHqsu/umf/qm48MILi7a2tuK8884rbr/99rJHqovNmzcXEVE8+eSTZY9SNwMDA8Xq1auL2bNnF9OnTy/e/OY3F5/5zGeKoaGhcd+nt00HANI0/WssAIDGISwAgDTCAgBIIywAgDTCAgBIIywAgDTCAgBIIywAgDTCAgBIIywAgDTCAgBIIywAgDT/D4DQf1sVdyynAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "psl.pwm_generator.generate(channels=4, frequency=500_000, duty_cycles=[0.1, 0.3, 0.5, 0.7], phases=[0, 0.2, 0.5, 0.8])\n",
    "t = psl.logic_analyzer.capture(channels=4, events=8)\n",
    "x1, y1, x2, y2, x3, y3, x4, y4 = psl.logic_analyzer.get_xy(t)\n",
    "plt.plot(x1, y1, x2, y2 + 1.1, x3, y3 + 2.2, x4, y4 + 3.3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38e53641-21ab-4e0f-a9c4-26181fcfae99",
   "metadata": {},
   "source": [
    "Here we have offset the graphs from each other on the y-axis to make them easier to tell apart.\n",
    "\n",
    "Note that the output from the logic analyzer's `capture` method is a list of timestamps for \"events\", i.e. logic level transissions, for each channel. In order to get something which is more suitable for plotting, the logic analyzer provides a `get_xy` method, which converts the timestamps into x and y values similar to the oscilloscope's output. Each channel has its own x and y pair.\n",
    "\n",
    "That's the basics of the PSLab's six core instruments!\n",
    "\n",
    "The PSLab also provides three types of serial buses: I2C, SPI, and UART. The buses can be used to connect external sensors and devices."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
